package com.example.demos.controller;

/*
 *1~100的和 
 */

public class HundredCaculate {
	public static void main(String[] args) {
			//计算1~100的和
			int sum = 0;
			for(int q = 1;q <= 100;q++) {
				sum += q;
			}
			System.out.println(1 + "+" + 2 + "+" + "..." + 100 + "=" + sum);
			
			//计算1~1/100的和
			double num = 0;
			for(double i = 1;i <= 100;i++) {
				num += 1/i;
			}
			System.out.println(1 + "+" + 1/2 + "+" + "..." + 1/100 + "=" + num);
			
		}
}
